package logic;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class PersonTableCellRenderer extends DefaultTableCellRenderer
{

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
	{
		setBackground(null);
		Component tableCellRendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		// need somthing better than cast all this here..
		PersonTableModel model = (PersonTableModel) table.getModel();
		String name = (String) table.getValueAt(row, 0);
		String comment = (String) table.getValueAt(row, 3);
		if (model.isInRaid(name))
			setBackground(Color.GREEN);
		if (comment != null && comment.contains("Won:"))
			setBackground(Color.RED);

		return tableCellRendererComponent;
	}

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

}
